home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / TreeNode.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-12-16  |  1.7 KB  |  89 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Image;
  4.  
  5. public class TreeNode {
  6.    TreeNode sibling;
  7.    TreeNode child;
  8.    TreeNode parent;
  9.    String text;
  10.    Image collapsedImage;
  11.    Image expandedImage;
  12.    int depth;
  13.    boolean isExpanded;
  14.    int numberOfChildren;
  15.  
  16.    public TreeNode(String var1) {
  17.       this(var1, (Image)null, (Image)null);
  18.    }
  19.  
  20.    public TreeNode(String var1, Image var2, Image var3) {
  21.       this.depth = -1;
  22.       this.isExpanded = false;
  23.       this.text = var1;
  24.       this.sibling = null;
  25.       this.child = null;
  26.       this.collapsedImage = var2;
  27.       this.expandedImage = var3;
  28.       this.numberOfChildren = 0;
  29.    }
  30.  
  31.    void setDepth(int var1) {
  32.       this.depth = var1;
  33.    }
  34.  
  35.    public int getDepth() {
  36.       return this.depth;
  37.    }
  38.  
  39.    public boolean isExpanded() {
  40.       return this.isExpanded;
  41.    }
  42.  
  43.    public boolean isExpandable() {
  44.       return this.child != null;
  45.    }
  46.  
  47.    public void expand() {
  48.       if (this.isExpandable()) {
  49.          this.isExpanded = true;
  50.       }
  51.  
  52.    }
  53.  
  54.    public void collapse() {
  55.       this.isExpanded = false;
  56.    }
  57.  
  58.    public void toggle() {
  59.       if (this.isExpanded) {
  60.          this.collapse();
  61.       } else {
  62.          if (this.isExpandable()) {
  63.             this.expand();
  64.          }
  65.  
  66.       }
  67.    }
  68.  
  69.    public Image getImage() {
  70.       return this.isExpanded && this.expandedImage != null ? this.expandedImage : this.collapsedImage;
  71.    }
  72.  
  73.    public void setExpandedImage(Image var1) {
  74.       this.expandedImage = var1;
  75.    }
  76.  
  77.    public void setCollapsedImage(Image var1) {
  78.       this.collapsedImage = var1;
  79.    }
  80.  
  81.    public String getText() {
  82.       return this.text;
  83.    }
  84.  
  85.    public void setText(String var1) {
  86.       this.text = new String(var1);
  87.    }
  88. }
  89.